﻿using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class NPCManger : ManagerBase
{
    public static NPCManger Instance { get; private set; }

    void Awake()
    {
        Instance = this;
    }

    public void SendMsg(MsgBase msg)
    {
        if (msg.GetManager() == ManagerID.NPCManager)
        {
            //本模块消息
            ProcessEvent(msg);
        }
        else //给msgCenter
        {
            MsgCenter.Instance.SendToMsg(msg);
        }
    }
    public GameObject GetGameObject(string name)
    {
        if (sonMembers.ContainsKey(name))
        {
            return sonMembers[name];
        }

        return null;
    }
    //规定了 开发方式  内存消耗 换取速度 方便
    private Dictionary<string, GameObject> sonMembers = new Dictionary<string, GameObject>();

    public void RegistGameObject(string name, GameObject obj)
    {
        if (!sonMembers.ContainsKey(name))
        {
            sonMembers.Add(name, obj);
        }
    }
    public void UnRegistGameObject(string name)
    {
        if (!sonMembers.ContainsKey(name))
        {
            sonMembers.Remove(name);
        }
    }
}
